<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            margin: 0;
            padding-top: 100px;
        }
        .box{
            width: 100%;
            height: 100px;
            background-color: #f00;
            position: fixed;
            top:0;
        }
    </style>
</head>
<body style="height: 2000px;">
    <!-- 
        固定定位
            脱离文档流，提升层级，针对窗口
     -->
    <div class="box"></div>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
    <h2>111</h2>
</body>
</html>